from django.db import models

from libs.CommonBaseModel import BaseModel


# Create your models here.
# 个人站点表
class Blog(BaseModel):
    site_title = models.CharField(verbose_name="站点标题", help_text="站点标题", max_length=32)
    site_name = models.CharField(verbose_name="站点名称", help_text="站点名称", max_length=32)
    site_theme = models.CharField(verbose_name="站点样式", help_text="站点样式", max_length=64)  # css/js的文件路径

    # 配置数据库元信息
    class Meta:
        # 指定数据库在后台显示的名字
        verbose_name = "个人站点表"
        verbose_name_plural = verbose_name
        #  指定数据库在后台显示的表名
        db_table = "blog"

    # 默认以当前站点名称返回
    def __str__(self):
        return self.site_name


# 广告信息表
class Adv(models.Model):
    title = models.CharField(verbose_name="广告标题", help_text="广告标题", max_length=64)
    content = models.TextField(verbose_name="广告详细内容", help_text="广告详细内容")
    create_time = models.DateTimeField(verbose_name="创建时间", help_text="创建时间", auto_now=True)
    update_time = models.DateTimeField(verbose_name="更新时间", help_text="更新时间", auto_now_add=True)
    mobile = models.CharField(verbose_name="手机号", help_text="手机号", max_length=11,
                              default="", blank=True)
    img = models.ImageField(verbose_name="广告图片", help_text="广告图片",
                            upload_to="advImg/", default="")
    is_background_img = models.BooleanField(verbose_name="是否是轮播图", default=False)


    #  配置数据库元信息
    class Meta:
        # 数据库名字
        db_table = "adv"
        #  指定数据库在后台显示的名字
        verbose_name = '广告信息表'
        verbose_name_plural = verbose_name
